package idv.cjcat.pyronova.nodes {
	import flash.display.IBitmapDrawable;
	import flash.geom.ColorTransform;
	import flash.geom.Matrix;
	import idv.cjcat.pyronova.render.RenderVisitor;
	
	public class Draw extends Node {
		
		public var source:IBitmapDrawable
		public var colorTransform:ColorTransform;
		public var blendMode:String;
		public var smoothing:Boolean;
		
		public function Draw(source:IBitmapDrawable = null, colorTransform:ColorTransform = null, blendMode:String = null, smoothing:Boolean = false) {
			this.source = source;
			this.colorTransform = colorTransform;
			this.blendMode = blendMode;
			this.smoothing = smoothing;
		}
		
		private var _matrix:Matrix = new Matrix();
		override public function render(visitor:RenderVisitor):void {
			if (source) {
				_matrix.identity();
				_matrix.concat(matrix());
				_matrix.concat(visitor.topMatrix());
				
				visitor.graphics().draw(source, _matrix, colorTransform, blendMode, smoothing);
			}
		}
	}
}